// SPDX-License-Identifier: GPL-2.0
/*
 * WORKQUEUE
 *
 * (C) 2024.05.20 BiscuitOS <buddy.zhang@aliyun.com>
 */
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/workqueue.h>

/* WORKQUEUE */
static struct workqueue_struct *BiscuitOS_wq;
/* WORK */
static struct work_struct work;

static void BiscuitOS_work_fn(struct work_struct *work)
{
	printk("WORK IS RUNNING\n");
}

static int __init BiscuitOS_init(void)
{
	/* CREATE WORKQUEUE */
	BiscuitOS_wq = create_workqueue("BiscuitOS WORKQUEUE");
	if (!BiscuitOS_wq)
		return -ENOMEM;

	/* INIT WORK */
	INIT_WORK(&work, BiscuitOS_work_fn);

	/* COMMIT WORK INTO WORKQUEUE */
	if (!queue_work(BiscuitOS_wq, &work)) {
		destroy_workqueue(BiscuitOS_wq);
		return -EFAULT;
	}

	return 0;
}

static void __exit BiscuitOS_exit(void) { }

module_init(BiscuitOS_init);
module_exit(BiscuitOS_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("BiscuitOS <buddy.zhang@aliyun.com>");
MODULE_DESCRIPTION("BiscuitOS SCHEDULE SUBSYSTEM");
